<?php

//检测表单字段是否为空
if (!isset($_REQUEST['name'])) {
    echo "请输入您的称呼！";
    exit;
}
if (!isset($_REQUEST['message'])) {
    echo "请输入文章内容！";
    exit;
}

$name = $_REQUEST['name'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$email = $_REQUEST['email'];

include '../conn.php';
$sql = "insert into comment(`name`, `subject`, `message`, `email`)"
    . " values('" . $name . "','" . $subject . "','" . $message . "','" . $email . "')";

if ($conn->query($sql) === TRUE) {
    echo "<script>alert('感谢您的意见~~');location.href='../index.php'</script>";
//    header("Location: user/center.php");

} else {
    echo '异常错误！';
}
